/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameAsistente.java
 *
 * Created on 4/03/2011, 08:31:26 PM
 */

package valida.Formularios.AsistenteArchivo;

import javax.swing.JPanel;

/**
 *
 * @author Andres Felipe
 */
public class FrameAsistente extends javax.swing.JFrame {

    private int panelActual=0;
    private JPanel[] panelesArhivo;
    /** Creates new form FrameAsistente */
    public FrameAsistente() {
        panelesArhivo= new JPanel[2];
        panelesArhivo[0] = new PanelNombreArchivo();
        panelesArhivo[1] = new PanelCamposArchivo();

        initComponents();
        PanelContenedorAsistente.add(panelesArhivo[0]);
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        PanelImagen = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        PanelContenedorAsistente = new javax.swing.JPanel();
        PanelNavegar = new javax.swing.JPanel();
        btnAtras = new javax.swing.JButton();
        btnSiguiente = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(530, 300));
        getContentPane().setLayout(new java.awt.GridBagLayout());

        PanelImagen.setBackground(new java.awt.Color(255, 255, 255));
        PanelImagen.setMaximumSize(new java.awt.Dimension(130, 350));
        PanelImagen.setMinimumSize(new java.awt.Dimension(130, 350));
        PanelImagen.setPreferredSize(new java.awt.Dimension(130, 350));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/valida/Recursos/Imagenes/CreaArchivos.png"))); // NOI18N

        javax.swing.GroupLayout PanelImagenLayout = new javax.swing.GroupLayout(PanelImagen);
        PanelImagen.setLayout(PanelImagenLayout);
        PanelImagenLayout.setHorizontalGroup(
            PanelImagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 130, Short.MAX_VALUE)
            .addGroup(PanelImagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelImagenLayout.createSequentialGroup()
                    .addGap(0, 1, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(0, 1, Short.MAX_VALUE)))
        );
        PanelImagenLayout.setVerticalGroup(
            PanelImagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
            .addGroup(PanelImagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(PanelImagenLayout.createSequentialGroup()
                    .addGap(0, 136, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(0, 136, Short.MAX_VALUE)))
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(PanelImagen, gridBagConstraints);

        PanelContenedorAsistente.setBackground(new java.awt.Color(255, 255, 255));
        PanelContenedorAsistente.setMaximumSize(new java.awt.Dimension(450, 350));
        PanelContenedorAsistente.setMinimumSize(new java.awt.Dimension(450, 350));
        PanelContenedorAsistente.setPreferredSize(new java.awt.Dimension(450, 350));
        PanelContenedorAsistente.setLayout(new java.awt.GridLayout());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        getContentPane().add(PanelContenedorAsistente, gridBagConstraints);

        PanelNavegar.setBackground(new java.awt.Color(255, 255, 255));
        PanelNavegar.setMaximumSize(new java.awt.Dimension(400, 50));
        PanelNavegar.setMinimumSize(new java.awt.Dimension(400, 50));
        PanelNavegar.setPreferredSize(new java.awt.Dimension(400, 50));
        PanelNavegar.setLayout(new java.awt.GridBagLayout());

        btnAtras.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        btnAtras.setText("< Atrás");
        btnAtras.setMaximumSize(new java.awt.Dimension(95, 30));
        btnAtras.setMinimumSize(new java.awt.Dimension(95, 30));
        btnAtras.setPreferredSize(new java.awt.Dimension(95, 30));
        btnAtras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtrasActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
        PanelNavegar.add(btnAtras, gridBagConstraints);

        btnSiguiente.setBackground(new java.awt.Color(255, 255, 255));
        btnSiguiente.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        btnSiguiente.setText("Siguiente >");
        btnSiguiente.setMaximumSize(new java.awt.Dimension(95, 30));
        btnSiguiente.setMinimumSize(new java.awt.Dimension(95, 30));
        btnSiguiente.setPreferredSize(new java.awt.Dimension(95, 30));
        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSiguienteActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.weightx = 0.1;
        PanelNavegar.add(btnSiguiente, gridBagConstraints);

        jButton3.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jButton3.setText("Finalizar");
        jButton3.setMaximumSize(new java.awt.Dimension(95, 30));
        jButton3.setMinimumSize(new java.awt.Dimension(95, 30));
        jButton3.setPreferredSize(new java.awt.Dimension(95, 30));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.weightx = 0.1;
        PanelNavegar.add(jButton3, gridBagConstraints);

        jButton4.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jButton4.setText("Cancelar");
        jButton4.setMaximumSize(new java.awt.Dimension(95, 30));
        jButton4.setMinimumSize(new java.awt.Dimension(95, 30));
        jButton4.setPreferredSize(new java.awt.Dimension(95, 30));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 20);
        PanelNavegar.add(jButton4, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(PanelNavegar, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSiguienteActionPerformed
      CambiarPestania(true);
    }//GEN-LAST:event_btnSiguienteActionPerformed

    private void btnAtrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtrasActionPerformed
        CambiarPestania(false);
    }//GEN-LAST:event_btnAtrasActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameAsistente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PanelContenedorAsistente;
    private javax.swing.JPanel PanelImagen;
    private javax.swing.JPanel PanelNavegar;
    private javax.swing.JButton btnAtras;
    private javax.swing.JButton btnSiguiente;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

    private void CambiarPestania(boolean isAumento) {
        if ((panelesArhivo.length) > (panelActual+1) && isAumento || !isAumento && 0 <= (panelActual-1)) {
            if (isAumento) {
                panelActual++;
            } else {
                panelActual--;
            }
            PanelContenedorAsistente.removeAll();
            PanelContenedorAsistente.add(panelesArhivo[panelActual]);
            PanelContenedorAsistente.revalidate();
            PanelContenedorAsistente.updateUI();
        }
    }

}
